// page_other/historybook/historybook.js
let app = getApp()
let yuming = app.globalData.yuming
const request = require('../../config/request');

Page({
  ...request,

  /**
   * 页面的初始数据
   */
  data: {
    heights: "",
    gao: '',
    title: '历史承诺书',
    yuming: yuming,
    total:'',
    image:[],
    year:'',
    images:''
  },
  backs() {
    wx.navigateBack({
      delta: 0
    })
  },
  fangda(e) {
    var img = e.currentTarget.dataset.img
    wx.previewImage({
      urls: [img]
    })
  },
  getHistoryList(){
    var url = '',
    url = 'Jinghexincheng/chengnuoshu_list'
    this.myRequest(yuming + url, {
      shopId: wx.getStorageSync('shopId'),
      year:2022,
      page:1
    }, "POST").then(res => {
     console.log(res,'-----------');
      if (res.data.code == 200) {
       this.setData({
          total:res.data.total,
          image:res.data.data,
          year:res.data.data[0].year
       })
       this.hahahha()
      }
    })
  },
  hahahha(){
    let arr =this.data.image.map(function(item) {
      return item.image[0]
    })
    this.setData({
      images:arr
    })
    console.log(arr);
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      heights: wx.getMenuButtonBoundingClientRect().top + 5,
      gao: wx.getMenuButtonBoundingClientRect().top + 40,
    })
    this.getHistoryList()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})